package io.github.uicdb.badskill.clent;

import io.github.uicdb.badskill.BadSkill;
import net.minecraft.client.KeyMapping;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.settings.IKeyConflictContext;
import net.minecraftforge.client.settings.KeyConflictContext;
import org.lwjgl.glfw.GLFW;

import java.util.ArrayList;
import java.util.List;

@OnlyIn(Dist.CLIENT)
public class ModInputs {
    public static final List<KeyMapping> ALL_KEY_MAPPINGS = new ArrayList<>();
    public static final String MOD_CATEGORY = "key.categories." + BadSkill.MODID;
    public static final KeyMapping OPEN_SKILL_PANEL = register(GLFW.GLFW_KEY_N, "key.open.skillpanel", MOD_CATEGORY);
    public static final KeyMapping OPEN_ATTRIBUTE_PANEL = register(GLFW.GLFW_KEY_M, "key.open.attribute", MOD_CATEGORY);

    @SuppressWarnings("all")
    private static KeyMapping register(int key, String keyName, String category) {
        return register(key, KeyConflictContext.IN_GAME, keyName, category);
    }

    @SuppressWarnings("all")
    private static KeyMapping register(int key, IKeyConflictContext context, String keyName, String category) {
        var keyMap = new KeyMapping(keyName, key, category);
        ALL_KEY_MAPPINGS.add(keyMap);
        keyMap.setKeyConflictContext(context);
        return keyMap;
    }
}
